package com.situ.struts.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class MyInterceptor implements Interceptor {
    public MyInterceptor() {
        System.out.println("MyInterceptor.MyInterceptor");
    }

    @Override
    public void init() {
        System.out.println("MyInterceptor.init");
    }

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        System.out.println("MyInterceptor.intercept 开始");
        // 有下一个拦截器执行下一个拦截器，没有就访问Action里面的方法
        String result = invocation.invoke();
        System.out.println("MyInterceptor.intercept 结束");
        return result;
    }

    @Override
    public void destroy() {
        System.out.println("MyInterceptor.destroy");
    }
}
